package main

import (
	"fmt"
	"os/exec"
	"strings"
)

func main() {
	option := []string{
		"ls-remote",
		"--heads",
		"https://gitee.com/x-x-mo/wx_build.git",
	}
	cmd := exec.Command("git", option...)
	out, err := cmd.CombinedOutput()
	if err != nil {
		fmt.Println("执行出错了")
		fmt.Println(err.Error())
		return
	}
	//fmt.Println(string(out))
	list := strings.Split(string(out), "\n")
	for _, v := range list {
		//fmt.Println("item:", v)
		itemList := strings.Split(v, "\t")
		if len(itemList) > 1 {
			branch := strings.ReplaceAll(itemList[1], "refs/heads/", "")
			if branch != "" {
				fmt.Println(branch)
			}
		}
	}
}
